<?php
require_once '../funciones/funciones.php';
$con = new MySQL;
switch ($_REQUEST['opc']){
    case "1": //carga todos subtemas asociados a un tema
        $tema = $_REQUEST['valor'];
        $tmp = ($_REQUEST['opc2'] == "1")?"<option value=''>Todos</option>":"";
        $sql = "select * from subtemas where temaId = $tema order by subtemaOrden";
        $result = $con->consulta($sql);
        $row = $con->unaFila($result);
        if(is_array($row)){
            $mostrar = "<select id='subtema' name='subtema' >"; //se quito onchange=\"cargaGrilla();\"
            $mostrar .= $tmp;
            do{
                $mostrar .= "<option value='{$row['subtemaId']}'>{$row['subtemaNombre']}</option>";
            }while($row = $con->unaFila($result));
            $mostrar .= "</select>";
        }
        else $mostrar = "No existen subtemas";
        echo $mostrar;
        break;
    case "2": //carga todos los niveles asociados a un tema
        $tema = $_REQUEST['valor'];
        $tmp = ($_REQUEST['opc2'] == "1")?"<option value=''>Todos</option>":"";
        $sql = "select * from niveles where temaId = $tema order by nivelOrden";
        $result = $con->consulta($sql);
        $row = $con->unaFila($result);
        if(is_array($row)){
            $mostrar = "<select id='nivel' name='nivel' >"; //se quito onchange=\"cargaGrilla();\"
            $mostrar .= $tmp;
            do{
                $mostrar .= "<option value='{$row['niveId']}'>{$row['nivel']}</option>";
            }while($row = $con->unaFila($result));
            $mostrar .= "</select>";
        }
        else $mostrar = "No existen Niveles";
        echo $mostrar;
        break;
    default :
        exit("error");
        break;
}
?>
